package com.workcell.workdata.im.mvc.controller.open;

import com.workcell.workdata.im.annotation.CreateAction;
import com.workcell.workdata.im.model.request.RobotMessageRequest;
import com.workcell.workdata.im.model.response.ResponseEntity;
import com.workcell.workdata.im.service.GroupRobotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/open/robot")
@Api(produces = "application/json", tags = "群机器人消息接口" )
@Validated
public class OpenRobotController {

    @Resource
    private GroupRobotService groupRobotService;

    @ApiOperation(httpMethod = "POST", value = "发送机器人消息",notes = "公共接口")
    @ApiImplicitParam(name = "uuid", value = "机器人UUID", paramType = "query",  dataTypeClass = String.class,example = "0")
    @PostMapping(value = "/message")
    @Validated(value = CreateAction.class)
    public ResponseEntity<Void> send(@RequestParam String uuid, @Valid @RequestBody RobotMessageRequest request) {
        return groupRobotService.send(uuid,request);
    }
}
